Skip to content

User: deprecate eraseCredentials#1739

Open
Hanmac wants to merge 2 commits into
sonata-project:5.xfrom
Hanmac:removeEraseCredentials
Open

User: deprecate eraseCredentials#1739
Hanmac wants to merge 2 commits into
sonata-project:5.xfrom
Hanmac:removeEraseCredentials

Conversation

@Hanmac
Copy link
Copy Markdown
Contributor

@Hanmac Hanmac commented Jan 12, 2026

Subject

I am targeting this branch, because should be BC. (I think)

Closes #1738.

Changelog

### Added

### Changed

### Deprecated
- User::eraseCredentials

### Removed

### Fixed

### Security

@Hanmac
Copy link
Copy Markdown
Contributor Author

Hanmac commented Jan 12, 2026

@VincentLanglet is that okay, or are the changes in the UserManager too much?

$password = $this->userPasswordHasher->hashPassword($user, $plainPassword);

$user->setPassword($password);
$user->eraseCredentials();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm but we still support Symfony 6.4 where eraseCredentials is not deprecated? 🤔 So I think completely removing the calls might break stuff for some people

Comment thread src/Model/User.php
}
}

#[\Deprecated]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it should be up to the users of this bundle to override the method on their user entity and add this attribute on their end? I feel like we cannot say if people are relying on this method to be called or not.

From what I understand Symfony will stop calling the method in case there is #[\Deprecated] present on the method.

Maybe we should do the same inside the UserManager classes? 🤔

$password = $this->userPasswordHasher->hashPassword($user, $plainPassword);

$user->setPassword($password);
$user->eraseCredentials();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@Hanmac
Copy link
Copy Markdown
Contributor Author

Hanmac commented Jan 12, 2026

@dmaicher the problem:

If the method is defined, and not deprecated, then Symfony will complain.
If the method is deprecated, and Sonata UserManager will call them, then PHP 8.4 will complain.

In both cases, it is a dilemma

@Hanmac
Copy link
Copy Markdown
Contributor Author

Hanmac commented Jan 20, 2026

@VincentLanglet your opinion to solve this dilemma?

Have our user manager call the method causes the same Deprecation Message I'm trying to avoid

@VincentLanglet
Copy link
Copy Markdown
Member

@dmaicher I feel like it could be ok to change this with a note in the Upgrade note/release note that may introduce a minor bc break if someone override the method (?)

@dmaicher
Copy link
Copy Markdown
Contributor

@dmaicher I feel like it could be ok to change this with a note in the Upgrade note/release note that may introduce a minor bc break if someone override the method (?)

yes I don't have a strong opinion on this. Fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecation: Implementing "UserInterface::eraseCredentials()" is deprecated since Symfony 7.3

3 participants